public class LoanRepayment{
    double a,y;
    int m;

    public LoanRepayment(double a,double y,int m){
        this.a = a;
        this.m = m;
        this.y = y;
    }

    void PrincipalInterest(){
        double i = y/12;
        double totalInterest = ((m+1)*a*i)/2;
        System.out.println("等额本金还款法："+totalInterest);
    }

    void InstallmentInterest(){
        double i = y/12;
        double totalInterest =(m*a*i*Math.pow(1+i,m))/(Math.pow(1+i,m)-1)-a;
        System.out.println("等额本息还款法："+totalInterest);
    }

}
